<?php

namespace App\Models\Shop;

use App\Helpers\SelfEncrypt;
use App\Models\BaseModel;
use Illuminate\Support\Facades\DB;

class OrderPaymentModel extends BaseModel
{
    protected $table = 'order_payment';

    protected $primaryKey = 'id';

    public $dateFormat = 'U';

    protected $dates = [
        'created_at',
        'updated_at',
        'pay_at',
    ];

    /**
     * 创建待支付单据
     * @param unknown $pay_no
     * @param unknown $pay_body
     * @param unknown $pay_detail
     * @param unknown $pay_money
     * @param unknown $type 订单类型  1. 商城订单  2.
     * @param unknown $pay_money
     */
    public function createPayment($shop_id, $out_trade_no, $pay_body, $pay_detail, $pay_money, $type, $type_alis_id)
    {
        $info = new self();
        $info->shop_id = $shop_id;
        $info->out_trade_no = $out_trade_no;
        $info->type = $type;
        $info->type_alis_id = $type_alis_id;
        $info->pay_body = $pay_body;
        $info->pay_detail = $pay_detail;
        $info->original_money = $pay_money;
        $info->pay_money = $pay_money;
        $info->pay_status = 0;

        return $info->save();
    }

}
